/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "accessprovider")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Accessprovider.findAll", query = "SELECT a FROM Accessprovider a"),
    @NamedQuery(name = "Accessprovider.findByMenuProviderId", query = "SELECT a FROM Accessprovider a WHERE a.accessproviderPK.menuProviderId = :menuProviderId"),
    @NamedQuery(name = "Accessprovider.findBySubmenuProviderId", query = "SELECT a FROM Accessprovider a WHERE a.accessproviderPK.submenuProviderId = :submenuProviderId"),
    @NamedQuery(name = "Accessprovider.findByOptionProviderId", query = "SELECT a FROM Accessprovider a WHERE a.accessproviderPK.optionProviderId = :optionProviderId"),
    @NamedQuery(name = "Accessprovider.findByProviderId", query = "SELECT a FROM Accessprovider a WHERE a.accessproviderPK.providerId = :providerId"),
    @NamedQuery(name = "Accessprovider.findByUserProviderId", query = "SELECT a FROM Accessprovider a WHERE a.accessproviderPK.userProviderId = :userProviderId")})
public class Accessprovider implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected AccessproviderPK accessproviderPK;
    
    @JoinColumns({
        @JoinColumn(name = "providerId", referencedColumnName = "providerId", insertable = false, updatable = false),
        @JoinColumn(name = "userProviderId", referencedColumnName = "userProviderId", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Userprovider userprovider;
    @JoinColumns({
        @JoinColumn(name = "menuProviderId", referencedColumnName = "menuProviderId", insertable = false, updatable = false),
        @JoinColumn(name = "submenuProviderId", referencedColumnName = "submenuProviderId", insertable = false, updatable = false),
        @JoinColumn(name = "optionProviderId", referencedColumnName = "optionProviderId", insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Optionprovider optionprovider;

    public Accessprovider() {
    }

    public Accessprovider(AccessproviderPK accessproviderPK) {
        this.accessproviderPK = accessproviderPK;
    }

    public Accessprovider(short menuProviderId, short submenuProviderId, short optionProviderId, int providerId, int userProviderId) {
        this.accessproviderPK = new AccessproviderPK(menuProviderId, submenuProviderId, optionProviderId, providerId, userProviderId);
    }

    public AccessproviderPK getAccessproviderPK() {
        return accessproviderPK;
    }

    public void setAccessproviderPK(AccessproviderPK accessproviderPK) {
        this.accessproviderPK = accessproviderPK;
    }

    public Userprovider getUserprovider() {
        return userprovider;
    }

    public void setUserprovider(Userprovider userprovider) {
        this.userprovider = userprovider;
    }

    public Optionprovider getOptionprovider() {
        return optionprovider;
    }

    public void setOptionprovider(Optionprovider optionprovider) {
        this.optionprovider = optionprovider;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (accessproviderPK != null ? accessproviderPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Accessprovider)) {
            return false;
        }
        Accessprovider other = (Accessprovider) object;
        if ((this.accessproviderPK == null && other.accessproviderPK != null) || (this.accessproviderPK != null && !this.accessproviderPK.equals(other.accessproviderPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Accessprovider[ accessproviderPK=" + accessproviderPK + " ]";
    }
    
}
